// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ExtendedReflection.Interpretation;
using Microsoft.ExtendedReflection.Metadata;
using Microsoft.ExtendedReflection.Utilities.Safe.Diagnostics;

namespace DySy.Engine
{
    internal sealed class ThisId : ISymbolIdWithType
    {
        TypeEx type;
        public ThisId(TypeEx type)
        {
            SafeDebug.AssumeNotNull(type, "type");

            this.type = type;
        }

        #region ISymbolId Members

        public string Description
        {
            get { return "this"; }
        }

        public Layout Layout
        {
            get { return Layout.Ref; }
        }

        public TypeEx Type
        {
            get { return this.type; }
        }

        public ObjectCreationTime ObjectCreationTime
        {
            get { return ObjectCreationTime.AheadOfTime; }
        }

        public Int64 GetPersistentHashCode()
        {
            return 0; // TODO
        }
        #endregion

        public override int GetHashCode()
        {
            return this.type.GlobalIndex ^ 467;
        }

        public override bool Equals(object obj)
        {
            ThisId other = obj as ThisId;
            return other != null && other.type == this.type;
        }
    }
}
